﻿
-- 人均工日考勤报表
CREATE procedure [dbo].[Report_Rjgr]
@qybmm varchar(100) = null,
@begindate datetime = null,
@enddate datetime = null
as
declare @gsdhgr int
select @gsdhgr=kqgrdh from Sys_Info
select case when aa.qybmm='' then '未知' else aa.qybmm end qybmm,bzrs,isnull(cqrs,0) cqrs,
isnull(zgs/3600,0) zgs,isnull(zgs/3600/@gsdhgr/cqrs,0) rjgr
from
(
select isnull(bzmc,'未知') qybmm,count(1) bzrs from vRyBzInfo
where @qybmm is null or isnull(bzmc,'未知')=@qybmm
group by bzmc
) aa
left join
(
select qybmm,count(1) cqrs,sum(ljgs) zgs from Compute_Rygs
where (@qybmm is null or qybmm=@qybmm) and (@begindate is null or kqsj>=@begindate)
and (@enddate is null or kqsj<=@enddate)
group by qybmm
) bb on(aa.qybmm=bb.qybmm)